/**
 * 
 */
package cc.angis.xiugallery;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import cc.angis.xiugallery.common.GlobalConst;
import cc.angis.xiugallery.image.ui.ImageGridActivity;

import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;

/**
 * @author user
 *
 */
public class SelectFavouriteFragment extends GroupingGridFragment {
	
	private String favId;
	
	
	public static SelectFavouriteFragment newInstance(String favId){
		SelectFavouriteFragment g = new SelectFavouriteFragment();
    	 final Bundle args = new Bundle();
    	 args.putInt(GlobalConst.INTENT_GROUP_TYPE, GlobalConst.INTENT_GROUP_TYPE_GALLERY);
    	 args.putString(GlobalConst.INTENT_FAVOURITE_ID, favId);
         g.setArguments(args);
         return g;
    }
	
	 @Override
	 public void onCreate(Bundle savedInstanceState) {
		 super.onCreate(savedInstanceState);
		 favId = getArguments().getString(GlobalConst.INTENT_FAVOURITE_ID);
		 ActionBar actionbar = getSherlockActivity().getSupportActionBar();
		 actionbar.setTitle(R.string.title_selectfrom);
	 }
	 
	 @Override
	public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
	}
	 
	 @Override
	    public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
	        final Intent i = new Intent(getActivity(), SelectImageGridActivity.class);
	        i.putExtra(GlobalConst.INTENT_BUCKET_ID,  mSourceProvider.getItem(position).toString());
	        i.putExtra(GlobalConst.INTENT_FAVOURITE_ID, favId);
	        startActivity(i);
	    }
}
